package com.fifth.business.controller;

import com.fifth.business.service.ProductService;
import com.fifth.common.pojo.dto.CommonResult;
import com.fifth.common.pojo.entity.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/business/product")
public class ProductController {
    @Autowired
    private ProductService productService;

    /**
     * 查询商品信息
     */
  /*  @GetMapping("/queryperson")
    public CommonResult storemanagement1(Integer currentPage,Integer pageSize,Goods goods,String rid) {
        CommonResult commonResult = productService.selectAll1(currentPage,pageSize,goods,rid);
        return new CommonResult(2000, "查寻成功", commonResult);
    }*/

    /**
     * 根据id删除商品信息
     */
    @PostMapping("/goodsdelete/{id}")
    public CommonResult goodsdelete(@PathVariable String id) {
        CommonResult commonResult = productService.goodsdelete(id);
        return new CommonResult(2000, "查寻成功", commonResult);
    }

    /**
     * 添加
     */
    @PostMapping("/goodsadd")
    public CommonResult goodsadd(@RequestBody Goods goods) {
        CommonResult commonResult = productService.goodsadd(goods);
        return new CommonResult(2000, "查寻成功", commonResult);
    }

    /**
     * 修改商品
     */
    @PostMapping("/goodsupdate")
    public CommonResult goodsupdate(@RequestBody Goods goods) {
        CommonResult commonResult = productService.goodupdate(goods);
        return new CommonResult(2000, "查寻成功", commonResult);

    }
}